package com.github.alenfive.utils;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

public class DataSourceUtils {
    public static NamedParameterJdbcTemplate jdbcTemplate = null;

	//在静态代码块中初始化连接池
    static {
        HikariDataSource ds = new HikariDataSource();
        ds.setJdbcUrl("jdbc:mysql://localhost:3306/rocket-api?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");
        ds.setUsername("root");
        ds.setPassword("root");
        ds.setDriverClassName("com.mysql.jdbc.Driver");
        jdbcTemplate = new NamedParameterJdbcTemplate(new JdbcTemplate(ds));
    }

}